var ValuesCals = function() {
	var R1 = 10000,R2 = 110000,R3 = 110000,R4 = 110000,R5 = 110000,E1 = 1,E2 = 1;
	var out;
	var overload = 5;
	var elementsTypes = {}; 
	
	this.onoverloaded = function() {
		
	}
	
	this.setValues = function(inR1, inR2, inR3, inR4, inR5, inE1, inE2) {
		R1 = inR1;
		R2 = inR2;
		R3 = inR3;
		R4 = inR4;
		R5 = inR5;
		E1 = inE1;
		E2 = inE2;
	};
	
	this.calculate = function() {
		J1 = (E1*(R2+R5+R4) - R2*E2)/[(R1+R2)*(R2+R5+R4) + R2*(R5+R4)];
		J2 = (-R1*J1 - R3*J1 + E1)/R2;
		J4 = J2 - J1;

		out = { R1: {  V:J1*R1, I:J1},
		R2: {  V:J2*R2, I:J2},
		R3: {  V:J1*R1, I:J1},
		R4: {  V:J4*R4, I:J4},
		R5: {  V:J4*R5, I:J4}};
		
		
		var i2 = 0;
        for(var i in out) {
        	console.log(Math.abs(out[i].I));
        	if(Math.abs(out[i].I) > 0.3) {
        		explode(parseInt(i2));
        	}
        	i2 ++; 
        }
	}
	
	//trick 
	this.setValue = function(R,val) {
		switch(R) {
		case  "R1":R1 = val; break;
		case  "R2":R2 = val; break;
		case  "R3":R3 = val; break;
		case  "R4":R4 = val; break;
		case  "R5":R5 = val; break;
		}
	}
	
	this.getValue = function(R) {
		return out[R];
	};
	
	this.isOverLoaded = function(R) {
		console.log(out);
		return Math.abs(out[R].I) > overload;
	};
	
	this.setElementType = function(slot, type) {
		elementsTypes[slot] = type;
	}

	this.getElementType = function(slot) {
		return elementsTypes[slot] ;
	}
}

engine = new ValuesCals();
engine.calculate();
engine.isOverLoaded("R5");
engine.getValue("R5");


$(function() {
formObj.setCallback(function(val) {

});

});
